package com.huse.usermanager.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huse.commonutls.ApiResult;
import com.huse.usermanager.entity.SysUser;
import com.huse.usermanager.entity.UserExtend;
import com.huse.usermanager.service.SysUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author xinxin
 * @since 2021-05-27
 */
@RestController
@RequestMapping("/usermanager/sys-user")
public class SysUserController {
    @Autowired
    private SysUserService sysUserService;

    @ApiOperation("用户基本信息分页查询")
    @GetMapping("/getUserByPage")
    public ApiResult getUserByPage(int start,int size){
        Page<SysUser> page = new Page<>(start,size);
        QueryWrapper<SysUser> wapper = new QueryWrapper();
//        排除password
        wapper.select(SysUser.class, info -> !info.getColumn().equals("password")
                && !info.getColumn().equals("update_time"));
        Page<SysUser> p = sysUserService.getUserByPage(page, wapper);
        return ApiResult.ok().data("userList",p.getRecords());
    }

    @ApiOperation("用户详细信息分页查询")
    @GetMapping("/userDetailInfoList")
    public ApiResult userDetailInfoList(int start,int size){
        return ApiResult.ok().data("userDetailInfoList",
                sysUserService.getUserDetailInfoList(start,size));
    }
}

